package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper//指定这是一个操作数据库的mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 根据客户名称查询账号
     * @param userName 用户名
     * @return
     */
    @Select("select * from user where username=${userName}")
    User findUserName(String userName);

    /**
     * 登录账号
     * @param username
     * @param password
     * @return 返回账号查询结果 0为密码或账号错误，1为账号正确
     */
    @Select("select * from user where username=#{userName} and password=#{password}")
    User getLongIn(@Param("userName") String username, @Param("password") String password);

    @Insert("insert into  user(username,password,address,phone,school)values(#{username},#{password},#{address},#{phone},#{school})")
    User getRegister(@Param("username") String username, @Param("password") String password,@Param("address")String address,
    @Param("phone")String phone,@Param("school")String school);
}
